/*
 * @author java_deng
 * @date 2025/2/5 11:47
 * @description
 */
package org.hbwl.controller;

import org.hbwl.po.AnimalPo;
import org.hbwl.service.AnimalService;
import org.hbwl.vo.AnimalVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/animal")
public class AnimalController extends BaseController{
    @Autowired
    private AnimalService animalService;

    @PostMapping("/list")
    public Object list(@RequestBody AnimalPo animalPo){
        return success(animalService.list(animalPo));
    }
    @PostMapping("/managerList")
    public Object managerList(@RequestBody AnimalPo animalPo){
        return success(animalService.managerList(animalPo));
    }

    @PostMapping("/addOrUpdate")
    public Object add(@RequestBody AnimalVo animalVo){
        if(animalVo.getId()!=null){
            animalService.update(animalVo);
        }else {
            animalService.add(animalVo);
        }
        return success("操作成功");
    }

    @PostMapping("audit")
    public Object audit(@RequestBody AnimalVo animalVo){
        animalService.audit(animalVo);
        return success("审核成功");
    }

    @GetMapping("/get")
    public Object get(Long id){
        return success(animalService.get(id));
    }

    @GetMapping("/delete")
    public Object delete(Long id){
        animalService.delete(id);
        return success("操作成功");
    }
}
